<template>
  <div class="app-container page" ref="homeScroll" @scroll="handleScroll">
    <div class="top-content">
      <div class="my-tabs">
        <div class="tabs-item" :class="{ active: activeTabs === 1 }" @click="changeTabs(1)">
          <p>选品中心</p>
          <span>可选商品：{{ total }}</span>
        </div>
        <div class="tabs-item" :class="{ active: activeTabs === 2 }" @click="changeTabs(2)">
          <p>商品预警</p>
          <span style="color: #ff3333">
            <!-- 待补商品：{{ total2 }} -->
          </span>
        </div>
      </div>
    </div>
    <selectPro v-if="activeTabs === 1" @changeTotal="getChangeTotal" />
    <warningPro v-if="activeTabs === 2" />
  </div>
</template>

<script setup>
import { ref, toRaw, onMounted } from "vue";
import selectPro from "./components/selectPro";
import warningPro from "./components/warningPro";

const activeTabs = ref(1);
const total = ref(0);
const total2 = ref(0);

const getChangeTotal = val => {
  total.value = val;
};

const changeTabs = index => {
  activeTabs.value = index;
};
</script>

<style lang="scss" scoped>
p {
  padding: 0;
  margin: 0;
}

.page {
  overflow-y: hidden;
  padding: 0;
  height: calc(100vh - 100px);
  position: relative;
}
.top-content {
  position: sticky;
  top: 0;
  padding: 20px;
  z-index: 2;
  background: #fff;
}

.my-tabs {
  display: flex;

  .tabs-item {
    width: 282px;
    padding: 10px 20px;
    // border: 1px solid #eee;
    border-bottom: none;
    border-radius: 12px 12px 0 0;
    display: flex;
    align-items: center;
    flex-direction: column;
    background-color: #f5f7fa;
    cursor: pointer;
    font-size: 12px;
    color: #86909c;

    p {
      font-size: 16px;
      color: #131414;
      line-height: 24px;
      display: flex;
      justify-content: space-between;

      .el-tag {
        height: 20px;
      }
    }

    &:first-of-type {
      margin-right: 20px;
    }

    &.active {
      background-color: white;
      box-shadow: 0px -5px 16px 0px rgba(4, 19, 74, 0.04);
    }
  }
}
</style>
